<template>
	<el-dialog draggable overflow v-model="visible" :title="'财务审核'" :width="1024" destroy-on-close
		@closed="$emit('closed')">

		<sk-upload v-model="form.attachments" :limit="10" draggable tip="" :disabled="true">
		</sk-upload>

		<el-form ref="dialogForm" label-width="70px" label-position="right">

			<el-row>
				<el-col :span="4">
					<el-form-item label="是否含税" prop="tax_id">
						<el-switch v-model="form.tax_id" :active-value="1" :inactive-value="0" disabled></el-switch>
					</el-form-item>
				</el-col>
				<el-col :span="5" align="客户">
					<el-form-item label="客户" prop="customer_id">
						<el-input v-model="form.customer.name" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="单号" prop="code">
						<el-input v-model="form.code" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="理单人" prop="singler_id">
						<el-input v-model="form.singler.name" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="单据日期" prop="singler_id">
						<el-input v-model="form.billdate" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="备注" prop="remark">
						<el-input v-model="form.remark" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="财审备注" prop="remark">
						<el-input v-model="form.financeremark"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>

		<sc-VxeTable ref="save" :data="form.details" :height="300" :tablecode="'market_retail_save_finance'">
		</sc-VxeTable>

		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">审 核</el-button>
		</template>
	</el-dialog>
</template>

<script>
import skDicSelect from "@/components/skDicSelect";
import skAutoChoose from "@/components/skAutoChoose";
import skSelectGroup from "@/components/skSelectGroup";
export default {
	emits: ["success", "closed"],
	components: {
		skAutoChoose,
		skDicSelect,
		skSelectGroup,
	},
	data() {
		return {
			form: {
				id: "",
				details: [],
				attachments: [],
			},

			visible: false,
			isSaveing: false,

		};
	},
	mounted() {
	},


	methods: {

		//显示
		open() {

			this.visible = true;

			return this;
		},

		//表单提交方法
		submit() {
			this.isSaveing = true;
			this.$API.market.retail.fauditmain.post(
				{ id: this.form.id, financeremark: this.form.financeremark }
			).then((res) => {
				if (res.code == 200) {
					this.$emit("success", this.form);
					this.visible = false;
					this.$message.success("操作成功");
				}
			}).finally(() => {
				this.isSaveing = false;
			})
		},
		async getItems(code) {
			var res = await this.$API.market.retail.details.get({
				filter: [{ code: code }],
			});
			if (res.code == 200) {
				this.form.details = res.data.rows;
			}
		},

		//表单注入数据
		async setData(data) {
			for (let i in data) {
				if (data[i] === null) delete data[i];
			}
			delete data.details;
			Object.assign(this.form, data);
			await this.getItems(this.form.code);
		},
	},
};
</script>

<style></style>
